package com.todo.partner.application.api.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.partner.application.convert.PartnerConvert;
import com.todo.partner.application.entity.bo.PartnerContentDetailBO;
import com.todo.partner.application.service.PartnerContentService;
import com.todo.partner.service.api.PartnerContentApi;
import com.todo.partner.service.api.response.PartnerDetailResponse;
import com.todo.partner.service.api.response.PartnerInfoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2025/2/25 23:41
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/api/partnerContent")
@Tag(name = "服务端-搭子内容接口", description = "服务端-搭子内容接口")
public class PartnerContentApiController implements PartnerContentApi {

    @Resource
    private PartnerContentService partnerContentService;

    @Override
    @Operation(summary = "根据id查询搭子内容详情")
    @PostMapping("/queryPartnerDetailById")
    public BizResponse<PartnerDetailResponse> queryPartnerDetailById(@RequestBody Long partnerId) {
        if (partnerId == null) {
            return BizResponse.paramError();
        }
        PartnerContentDetailBO partnerContentDetailBO = partnerContentService.queryContentPartnerByContentId(partnerId);
        return BizResponse.success(PartnerConvert.convertToPartnerDetailResponse(partnerContentDetailBO));
    }

    @Override
    @Operation(summary = "根据id列表查询搭子内容信息列表")
    @PostMapping("/queryPartnerInfoByIdList")
    public BizResponse<List<PartnerInfoResponse>> queryPartnerInfoByIdList(@RequestBody List<Long> partnerIdList) {
        if (CollectionUtils.isEmpty(partnerIdList)) {
            return BizResponse.paramError();
        }
        List<PartnerContentDetailBO> partnerContentDetailBOS = partnerContentService.queryContentPartnerList(partnerIdList);
        return BizResponse.success(PartnerConvert.convertToPartnerInfoResponseList(partnerContentDetailBOS));
    }
}
